function Estimate(DATA, OUT, price_iv)

    close all
    format long g
    
    tolerance = 1e-12;
    
    addpath('helpers')
    addpath('rcnl_demand')
    addpath('rcnl_supply')
    
    
    [df, dfull, cdindex] = load_data_full(DATA);
    [xlinear, ~, xnonlin, fe, ~, zdemand, ~, zinside, ~] = final_variables(df, price_iv, 'L');
    
    s_jt     = df.s_jt;
    p_jt     = df.p_jt;
    prodid   = df.prodid;
    market   = df.cdid;
    cluster  = df.cityid;
    dresults = struct;
    Pi       = [0; 0; 0]; 
    rho      = 0;
    par_rest = [];
    varargin = {};

    coefs_sim = struct;
    coefs_sim.dist_mis = nan;

    try
        [dresults, ~] = estimate_rcnl( ...
            Pi,      ...
            rho,     ...
            s_jt,    ...
            p_jt,    ...
            prodid,  ...
            xlinear, ...
            xnonlin, ...
            zdemand, ...
            zinside, ...
            fe,      ...
            market,  ...
            dfull,   ...
            cluster, ...
            "L",  ...
            par_rest, ...
            coefs_sim, ...
            tolerance, ...
            varargin{:});
        dflags = 0
    catch err
        fprintf('%s: %s\n', err.identifier, err.message);
        dflags = 1
    end

    disp(['OUT path: ', OUT]);
    if ~exist(OUT, 'dir')
        error('The output directory OUT does not exist: %s', OUT);
    end

    output_dir = fullfile(OUT, '../scalars');
    if ~exist(output_dir, 'dir')
        mkdir(output_dir);
        disp(['Created directory: ', output_dir]);
    end

    texfile = fullfile(output_dir, sprintf('mean_ownElas_%s.tex', price_iv));
    disp(['Full texfile path: ', texfile]);

    [fid, errmsg] = fopen(texfile, 'w');
    if fid == -1
        error('Cannot open file: %s\nError: %s', texfile, errmsg);
    end

    mean_ownElas = mean(dresults.ownElas);
    tex_command = sprintf('\\newcommand{\\MeanOwnElas%s}{%.2f}\n', price_iv, mean_ownElas);
    fprintf(fid, '%s', tex_command);
    fclose(fid);

    disp(['Mean own elasticity saved to ' texfile]);

    end

